﻿using AdverseEventReportSystem.BLL;
using AdverseEventReportSystem.BLL.ServiceReference1;
using AdverseEventReportSystem.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AdverseEventReportSystem.Web.Areas.Personnel
{
    public class EditNurseLevelController : BaseController
    {
        // GET: Personnel/EditNurseLevel
        public ActionResult Index(int id = 0, int pageType = 0, string detailsViewBtns = "", int status = 0)
        {
            ViewBag.Id = id;
            ViewBag.PageType = pageType;
            ViewBag.DetailsViewBtns = detailsViewBtns;
            ViewBag.Status = status;
            return View();
        }

        /// <summary>
        /// 获取能级晋升申请详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult GetNurseLevelInfo(string id)
        {
            OperateResult resultInfo = NurseLevelManager.GetNurseLevelInfo(id);
            return JsonDate(resultInfo);
        }

        /// <summary>
        /// 通过UserID检索名字入院时间职能等信息
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPersonnelUserID()
        {
            FunctionAndPermissionsSoapClient service = new FunctionAndPermissionsSoapClient();
            ResultHelperOfPersonnelUserID serviceResult = service.getPersonnelUserID(LoginManager.GetLoginUser().Personnel_id);
            PersonnelUserID p = new PersonnelUserID();
            if (serviceResult.S)
            {
                p = serviceResult.D;
            }
            var result = new { p = p, departmentName = loginUser.CurrDepName };
            return JsonDate(result);
        }

        /// <summary>
        /// 添加/编辑能级晋升申请
        /// </summary>
        /// <param name="nurseLevel"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Save(NurseLevel nurseLevel)
        {
            OperateResult resultInfo = NurseLevelManager.Save(nurseLevel);
            return JsonDate(resultInfo);
        }
    }
}